const newswebService = require('../../services/web/newswebService')
const newswebController = {
    GetNewsList:async (req,res)=>{
        const result = await  newswebService.GetNewsList()
        if(result.code===0){
            res.send({
                code:0,
                msg:'获取失败'
            })
        }
        else 
        res.send({
                code:200,
                result:result,
                msg:'获取成功',
                
            })
    },
    SearchNews:async (req,res)=>{

        const result = await newswebService.SearchNews(req.body.keyword)
        if(result.code===400){
            res.send({
                code:400,
                err:result.err,
                msg:'搜索失败'
            })
        }
        else 
        res.send({
                code:200,
                result:result,
                msg:'搜索成功',
                
            })

    },
    GetNewNewsList:async (req,res)=>{
                
           const result= await newswebService.GetNewNewsList(req.body.limit)
        
           if(result.code===400){
            res.send({
                code:400,
                err:result.err,
                msg:'获取失败'
            })
        }
        else 
        res.send({
                code:200,
                result:result,
                msg:'获取成功',
                
            })
    }
}

module.exports = newswebController